package com.swang.pms.service.common.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.swang.pms.dal.common.SysParamDao;
import com.swang.pms.model.common.GridUtil;
import com.swang.pms.model.common.Pager;
import com.swang.pms.model.dto.common.SysParamDto;
import com.swang.pms.service.common.SysParamService;

/**
 * @ClassName: SysParamServiceImpl
 * @Description: 系统参数
 * @author 王泽
 * @date 2017年3月16日 下午9:45:51
 */
@Service("sysParamService")
public class SysParamServiceImpl implements SysParamService {

    @Resource
    SysParamDao sysParamDao;

    public Pager pageFindSysParamGrid(Pager page, SysParamDto sysParamDto) {
        String[] paramSerial = new String[] { "id", "param_code", "param_name", "sys_type", "biz_module", "data_type", "param_value",
                "default_value", "status", "remark", "extend_value", "gmt_create", "gmt_modify", "sort_num", "operator" };
        sysParamDto.setStartIndex(page.getRowStartIndex());
        sysParamDto.setPageSize(page.getPageSize());
        List<Map<String, Object>> list = this.sysParamDao.pageFindSysParamByDto(sysParamDto);
        sysParamDto.setStartIndex(null);
        sysParamDto.setPageSize(null);
        page.setRowCount(this.sysParamDao.pageFindSysParamCountByDto(sysParamDto));
        page.setGridr(GridUtil.getGridList(list, paramSerial, page.getRowStartIndex(), page.getPageSize(), page.getRowCount(), true));
        return page;
    }

    public int updateByPrimaryKey(SysParamDto sysParamDto) {
        return this.sysParamDao.updateByPrimaryKey(sysParamDto);
    }

    public SysParamDto getParamByDto(SysParamDto sysParamDto) {
        return sysParamDao.getParamByDto(sysParamDto);
    }
}
